home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / packet / terminal / tpk_182 / info.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-01  |  2.1 KB  |  104 lines

  1. /*
  2.  
  3. INFO.C
  4.  
  5. Ce programme est utilisable comme commande a distance de TPK.
  6. Ce n'est pas un serveur accessible par message, son fonctionnement est
  7. identique au serveur SERVINFO.
  8.  
  9. Il repond aux commandes /INFO ou /INFO nnn.
  10.  
  11. Il retourne en reponse le fichier INFO.000 dans le premier cas et le
  12. fichier INFO.nnn dans le second cas.
  13.  
  14. Le fichier de configuration INFO.CFG devra etre dans le repertoire de
  15. TPK (comme INFO.EXE) et peut contenir deux commandes:
  16.  
  17. PATH
  18.  
  19. Pour indiquer le chemin des fichiers INFO
  20. (Cette commande est indispensable)
  21. Ex: PATH C:\TPK\INFO
  22.  
  23. FILE
  24.  
  25. Pour eventuellement modifier le nom des fichiers INFO
  26. (Cete commande est facultative, implicitement le nom est INFO)
  27. Ex: FILE TEXT_INF
  28. Dans ce cas INFO ira chercher des fichiers TEXT_INF.000 a 999
  29.  
  30. */
  31. #include <stdio.h>
  32. #include <stdlib.h>
  33. #include <string.h>
  34. #include <ctype.h>
  35.  
  36. void ReadCfg(void);
  37.  
  38. char str[255];
  39. char line[256];
  40. char Path_Tpk[129];
  41. char Path_Info[129];
  42. char FiInfo[9]="INFO";
  43.  
  44. void main(int argc, char *argv[])
  45. {
  46. char str1[129];
  47. char str2[4];
  48. FILE *fichin;
  49.  
  50. if (argc) strncpy(str1, argv[1], 3);
  51.  
  52. ReadCfg();
  53.  
  54. sprintf(str2, "%03d", atoi(str1));
  55. sprintf(str1, "%s%s.%s", Path_Info, FiInfo, str2);
  56. if ((fichin=fopen(str1, "r")) != NULL)
  57.     {
  58.     while (fgets(str, 80, fichin) !=NULL)
  59.         {
  60.         printf("%s", str);
  61.         }
  62.     fclose (fichin);
  63.     }
  64. else
  65.     {
  66.     printf("Pas d'info %s\n", str2);
  67.     }
  68. }
  69.  
  70. /* Lecture configuration */
  71.  
  72. void ReadCfg(void)
  73. {
  74. int i;
  75. char cmd[81];
  76. char par1[81];
  77. char par2[81];
  78. char *s;
  79. FILE *fichin;
  80.  
  81. if (s=strcpy(str, Path_Tpk),s=strcat(str, "INFO.CFG"),
  82.     (fichin=fopen(str, "r")) != NULL)
  83.     {
  84.     while (fgets(str, 80, fichin) !=NULL)
  85.         {
  86.         i=sscanf(str, "%s", cmd);
  87.         if (i){
  88.             i=sscanf(str, "%s %s %s", cmd,par1,par2);
  89.             strcpy(cmd,strupr(cmd));
  90.             /* Chemin des fichiers INFO.xxx */
  91.             if (strcmp("PATH",cmd)==0)
  92.                 {
  93.                 strncpy(Path_Info, strupr(par1), 128);
  94.                 if ((*(Path_Info+strlen(Path_Info))) != '\\')
  95.                     strcat(Path_Info, "\\");
  96.                 }
  97.             /* Nom des fichiers INFO */
  98.             if (strcmp("FILE",cmd)==0) strncpy(FiInfo, strupr(par1), 8);
  99.             }
  100.         }
  101.     fclose(fichin);
  102.     }
  103. }
  104.